package com.zhuoli.service.springboot.kafka.consumer;

import com.zhuoli.service.springboot.kafka.consumer.config.KafkaConsumerConfig;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Import;

/**
 * @Author: zhuoli
 * @Date: 2018/9/4 11:14
 * @Description:
 */
@SpringBootApplication
@Import(value = {KafkaConsumerConfig.class})
public class KafkaConsumerApplicationContext {
    public static void main(String[] args) {
        SpringApplication.run(KafkaConsumerApplicationContext.class, args);
    }

    @Bean
    public EmbeddedServletContainerCustomizer containerCustomizer() {
        return container -> container.setPort(8081);
    }

    /*
    spring boot 2.* EmbeddedServletContainerCustomizer missing
    @Bean
    public TomcatServletWebServerFactory containerFactory() {
        return new TomcatServletWebServerFactory() {
            protected void customizeConnector(Connector connector) {
                int maxSize = 50000000;
                super.customizeConnector(connector);
                connector.setMaxPostSize(maxSize);
                connector.setPort(8081);
                connector.setMaxSavePostSize(maxSize);
                if (connector.getProtocolHandler() instanceof AbstractHttp11Protocol) {
                    ((AbstractHttp11Protocol <?>) connector.getProtocolHandler()).setMaxSwallowSize(maxSize);
                    logger.info("Set MaxSwallowSize "+ maxSize);
                }
            }
        };

    }*/
}
